import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

const routes = [
  {
    path:'/main',
    name:'main',
    component:()=>import('@/views/Main'),
    redirecrt:'/home',
    children:[
		  {
			path:'/home',
			component:() =>import('@/views/Control')  //控制台
		  },
		  {
			path:'/homes',
			component:() =>import('@/views/Homes/look.vue'), //房间管理
			children:[
				{
					path:'/add',
					component:() => import('@/views/Homes/add.vue') //添加房间
				},
				{
					path:'/update',
					component:() =>import('@/views/Homes/update.vue') //修改房间信息
				}
			]
		  },
		{
		   path:'/comment',
		   component:() =>import('@/views/Comment') //删除用户
		},
		{
		   path:'/employee/staff',
		   component:()=>import('@/views/employee/Staff.vue')//员工表
		},
		{
		   path:'/employee/add',
		   component:()=>import('@/views/employee/add.vue')//增加员工
		},
		{
		   path:'/employee/update',
		   component:()=>import('@/views/employee/update.vue')//修改信息
		},
		{
		   path:'/parking/manage',
		   component:()=>import('@/views/Parking/manage.vue'),//修改信息
		},
    ]
  }, 
  {
    path:'/',
    name:'login',
    component:()=>import('@/views/Login')
  },
]
//  //导航守卫
// touter.beforeEach((to,from,next) => {
//   //to 将要访问的路径
//   //from 代表从哪个路径跳转过来
//   //next 是一个函数，表示放行 next('/login') 强制跳转路径
//   if(to.path === '/login') return next();
//   //获取token
//   const tokenStr = window.sessionStorage.getItem('token')
//   //判断是否有token 没有直接去登录页
//   if(!tokenStr) return next('/login')
//   //有了直接放行
//   next()
// })

const router = new VueRouter({
  routes
})

export default router
